<template>
  <div class="deployment-mode">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-content">
        <div class="header-left">
          <h1 class="page-title">
            终端部署
            <el-icon class="title-icon"><Operation /></el-icon>
          </h1>
          <p class="page-description">
            如何部署的在线终端管理系统是支持的的部署方式的基础部署方式上，支持一个有序的中继部署方式，实现对终端
            终端设备的内容管理，这样了解终端的的基本运行状况及对其的监控
          </p>
        </div>
        <div class="header-right">
          <div class="header-illustration">
            <!-- 3D图标插图 -->
            <div class="illustration-container">
              <div class="floating-icon icon-1">
                <el-icon><Monitor /></el-icon>
              </div>
              <div class="floating-icon icon-2">
                <el-icon><Connection /></el-icon>
              </div>
              <div class="floating-icon icon-3">
                <el-icon><Operation /></el-icon>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 安装和部署方式 -->
    <div class="deployment-section">
      <h2 class="section-title">安装和部署方式</h2>

      <div class="deployment-options">
        <el-row :gutter="20">
          <!-- 在线安装 -->
          <el-col :xs="24" :md="12">
            <div class="deployment-card online" @click="selectDeployment('online')">
              <div class="card-icon">
                <el-icon><Download /></el-icon>
              </div>
              <div class="card-content">
                <h3 class="card-title">
                  支持在线安装
                  <el-tag type="success" size="small">推荐</el-tag>
                </h3>
                <p class="card-description">
                  通过网络直接下载并自动安装最新版本，支持自动更新和配置同步
                </p>
              </div>
            </div>
          </el-col>

          <!-- 盒子下载安装 -->
          <el-col :xs="24" :md="12">
            <div class="deployment-card box" @click="selectDeployment('box')">
              <div class="card-icon">
                <el-icon><Box /></el-icon>
              </div>
              <div class="card-content">
                <h3 class="card-title">盒子下载安装</h3>
                <p class="card-description">
                  从本地AI盒子服务器下载安装包，适用于内网环境部署
                </p>
              </div>
            </div>
          </el-col>

          <!-- 公有云下载支持 -->
          <el-col :xs="24" :md="12">
            <div class="deployment-card cloud" @click="selectDeployment('cloud')">
              <div class="card-icon">
                <el-icon><Upload /></el-icon>
              </div>
              <div class="card-content">
                <h3 class="card-title">公有云下载支持</h3>
                <p class="card-description">
                  从公有云平台下载安装包，支持多种云服务商，确保下载稳定性
                </p>
              </div>
            </div>
          </el-col>

          <!-- 离线安装 -->
          <el-col :xs="24" :md="12">
            <div class="deployment-card offline" @click="selectDeployment('offline')">
              <div class="card-icon">
                <el-icon><FolderOpened /></el-icon>
              </div>
              <div class="card-content">
                <h3 class="card-title">离线安装：客户自己下载</h3>
                <p class="card-description">
                  客户手动下载安装包进行离线部署，适用于完全隔离的网络环境
                </p>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>

    <!-- 在线安装步骤 -->
    <div class="deployment-steps" v-if="selectedDeployment === 'online'">
      <div class="steps-header">
        <el-icon><Download /></el-icon>
        <span>在线安装</span>
      </div>
      <p class="steps-description">
        通过网络直接下载并自动安装最新版本，支持自动更新和配置同步
      </p>

      <div class="action-buttons">
        <el-button type="primary" size="large" @click="startOnlineInstall">
          <el-icon><Download /></el-icon>
          开始在线安装
        </el-button>
        <el-button type="success" @click="showOnlineScript">
          <el-icon><Document /></el-icon>
          查看安装脚本
        </el-button>
      </div>
    </div>

    <!-- 盒子下载安装步骤 -->
    <div class="deployment-steps" v-if="selectedDeployment === 'box'">
      <div class="steps-header">
        <el-icon><Box /></el-icon>
        <span>盒子下载安装</span>
      </div>
      <p class="steps-description">
        从本地AI盒子服务器下载安装包，适用于内网环境部署
      </p>

      <div class="download-buttons">
        <el-button type="primary" size="large" @click="downloadFromBox('windows')">
          <el-icon><Monitor /></el-icon>
          Windows版本
        </el-button>
        <el-button type="warning" size="large" @click="downloadFromBox('linux')">
          <el-icon><Monitor /></el-icon>
          Linux版本
        </el-button>
      </div>
    </div>

    <!-- 公有云下载步骤 -->
    <div class="deployment-steps" v-if="selectedDeployment === 'cloud'">
      <div class="steps-header">
        <el-icon><Upload /></el-icon>
        <span>公有云下载支持</span>
      </div>
      <p class="steps-description">
        从公有云平台下载安装包，支持多种云服务商，确保下载稳定性
      </p>

      <div class="cloud-options">
        <el-row :gutter="15">
          <el-col :span="8">
            <el-button type="primary" size="large" @click="downloadFromCloud('aliyun')" class="cloud-btn">
              <el-icon><Upload /></el-icon>
              阿里云下载
            </el-button>
          </el-col>
          <el-col :span="8">
            <el-button type="success" size="large" @click="downloadFromCloud('tencent')" class="cloud-btn">
              <el-icon><Upload /></el-icon>
              腾讯云下载
            </el-button>
          </el-col>
          <el-col :span="8">
            <el-button type="warning" size="large" @click="downloadFromCloud('huawei')" class="cloud-btn">
              <el-icon><Upload /></el-icon>
              华为云下载
            </el-button>
          </el-col>
        </el-row>
      </div>
    </div>

    <!-- 离线安装步骤 -->
    <div class="deployment-steps" v-if="selectedDeployment === 'offline'">
      <div class="steps-header">
        <el-icon><FolderOpened /></el-icon>
        <span>离线安装：客户自己下载</span>
      </div>
      <p class="steps-description">
        客户手动下载安装包进行离线部署，适用于完全隔离的网络环境。请根据您的操作系统选择对应的安装包
      </p>

      <div class="download-buttons">
        <el-button type="primary" size="large" @click="downloadOffline('windows')">
          <el-icon><Monitor /></el-icon>
          Windows安装包
        </el-button>
        <el-button type="warning" size="large" @click="downloadOffline('linux')">
          <el-icon><Monitor /></el-icon>
          Linux安装包
        </el-button>
      </div>

      <div class="offline-instructions">
        <el-alert
          title="离线安装说明"
          type="info"
          :closable="false"
          show-icon>
          <template #default>
            <ol>
              <li>下载对应操作系统的安装包</li>
              <li>将安装包传输到目标设备</li>
              <li>在目标设备上运行安装程序</li>
              <li>按照安装向导完成配置</li>
            </ol>
          </template>
        </el-alert>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import {
  Operation, Monitor, Connection, Lock, Tools, Setting,
  Download, Document, Box, Upload, FolderOpened
} from '@element-plus/icons-vue'

// 响应式数据
const selectedDeployment = ref('online')

// 方法
const selectDeployment = (type) => {
  selectedDeployment.value = type
  ElMessage.success(`已选择${getDeploymentName(type)}`)
}

const getDeploymentName = (type) => {
  const names = {
    online: '支持在线安装',
    box: '盒子下载安装',
    cloud: '公有云下载支持',
    offline: '离线安装：客户自己下载'
  }
  return names[type] || type
}

// 在线安装相关方法
const startOnlineInstall = () => {
  ElMessage.info('正在启动在线安装程序...')
  // 这里可以添加实际的在线安装逻辑
}

const showOnlineScript = () => {
  ElMessage.info('显示在线安装脚本')
  // 这里可以显示安装脚本内容
}

// 盒子下载相关方法
const downloadFromBox = (platform) => {
  ElMessage.info(`正在从AI盒子下载${platform}版本...`)
  // 这里可以添加从盒子下载的逻辑
}

// 公有云下载相关方法
const downloadFromCloud = (provider) => {
  const providerNames = {
    aliyun: '阿里云',
    tencent: '腾讯云',
    huawei: '华为云'
  }
  ElMessage.info(`正在从${providerNames[provider]}下载安装包...`)
  // 这里可以添加从公有云下载的逻辑
}

// 离线安装相关方法
const downloadOffline = (platform) => {
  const platformNames = {
    windows: 'Windows',
    mac: 'macOS',
    linux: 'Linux'
  }
  ElMessage.info(`正在下载${platformNames[platform]}离线安装包...`)
  // 这里可以添加离线下载的逻辑
}
</script>

<style scoped>
.deployment-mode {
  max-width: 1200px;
  margin: 0 auto;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 0;
}

.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40px 30px;
  color: white;
  position: relative;
  overflow: hidden;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.header-left {
  flex: 1;
  max-width: 600px;
}

.page-title {
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 20px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-icon {
  font-size: 28px;
}

.page-description {
  font-size: 16px;
  line-height: 1.6;
  opacity: 0.9;
  margin: 0;
}

.header-right {
  flex: 0 0 300px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.illustration-container {
  position: relative;
  width: 200px;
  height: 200px;
}

.floating-icon {
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: float 3s ease-in-out infinite;
}

.floating-icon .el-icon {
  font-size: 24px;
  color: white;
}

.icon-1 {
  top: 20px;
  left: 50px;
  animation-delay: 0s;
}

.icon-2 {
  top: 80px;
  right: 20px;
  animation-delay: 1s;
}

.icon-3 {
  bottom: 30px;
  left: 20px;
  animation-delay: 2s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.deployment-section {
  background: white;
  padding: 40px 30px;
}

.section-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 30px 0;
  color: #333;
}

.deployment-options {
  margin-bottom: 40px;
}

.deployment-card {
  background: white;
  border: 2px solid #e4e7ed;
  border-radius: 12px;
  padding: 20px 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.deployment-card:hover {
  border-color: #409eff;
  box-shadow: 0 8px 25px rgba(64, 158, 255, 0.1);
  transform: translateY(-2px);
}

.deployment-card.online {
  border-color: #67c23a;
  background: linear-gradient(135deg, #67c23a10 0%, #67c23a05 100%);
}

.deployment-card.box {
  border-color: #409eff;
  background: linear-gradient(135deg, #409eff10 0%, #409eff05 100%);
}

.deployment-card.cloud {
  border-color: #e6a23c;
  background: linear-gradient(135deg, #e6a23c10 0%, #e6a23c05 100%);
}

.deployment-card.offline {
  border-color: #f56c6c;
  background: linear-gradient(135deg, #f56c6c10 0%, #f56c6c05 100%);
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
}

.online .card-icon {
  background: linear-gradient(135deg, #67c23a, #85d47e);
}

.box .card-icon {
  background: linear-gradient(135deg, #409eff, #5dade2);
}

.cloud .card-icon {
  background: linear-gradient(135deg, #e6a23c, #f4d03f);
}

.offline .card-icon {
  background: linear-gradient(135deg, #f56c6c, #ff8a80);
}

.card-icon .el-icon {
  font-size: 24px;
  color: white;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.card-description {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
  margin: 0;
}

.deployment-steps {
  background: white;
  padding: 30px;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.steps-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.steps-header .el-icon {
  color: #409eff;
}

.steps-description {
  color: #666;
  line-height: 1.6;
  margin: 0 0 25px 0;
}

.download-buttons {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.action-buttons {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.cloud-options {
  margin-top: 20px;
}

.cloud-btn {
  width: 100%;
  height: 50px;
}

.offline-instructions {
  margin-top: 25px;
}

.offline-instructions ol {
  margin: 10px 0 0 20px;
  padding: 0;
}

.offline-instructions li {
  margin-bottom: 8px;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }

  .header-right {
    margin-top: 30px;
  }

  .deployment-card {
    margin-bottom: 20px;
  }

  .download-buttons,
  .action-buttons {
    justify-content: center;
  }

  .cloud-options .el-col {
    margin-bottom: 10px;
  }
}
</style>
